
const Mock = require('mockjs');
// 获取 mock.Random 对象
 const Random = Mock.Random;
 // mock一组数据
 const produceData_1 = function (opt,n) {
  //console.log('opt', opt);
  let articles = [];
  for (let i = 0; i < 8; i++) {
   let newArticleObject = {
    title:Random.ctitle(10,20),
    details:Random.csentence(10,40),
    price:Random.natural(5000,9999),
    nprice:Random.natural(1000,4999),

    imgsrc:Random.dataImage('160x160', 'mock的图片'),
    importantT:{
        title:Random.cword(4),
        bgcolor:"background:"+Random.rgb(),
    },
    evaluate:{
        etext:Random.csentence(20,30),
        ename:Random.cname()
    } 
   }
   articles.push(newArticleObject)
  }
  return {
   data: articles
  }
 }
Mock.mock('/jiang', /post|get/i, produceData_1);

const produceData_2 = function (opt,n) {
    //console.log('opt', opt);
    let articles = [];
    for (let i = 0; i < 10; i++) {
        let newArticleObject = {
            title:Random.ctitle(5),
            Plist:[]
        }
        articles.push(newArticleObject)
        for(let j = 0; j<22;j++){
            let newproductlist = 
                {
                    name:Random.ctitle(4,8),
                    imgsrc:Random.dataImage('160x160', 'mock的图片')
                }
            articles[i].Plist.push(newproductlist);
        }
    }
    return {
     data: articles
    }
   }
  Mock.mock('/jun', /post|get/i, produceData_2);